home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 November: Tool Chest / Dev.CD Nov 98 TC.toast / Sample Code / Snippets / Toolbox / Tabs LDEF 1.0 / Sources / PatchListLDEF.c < prev    next >
Encoding:
Text File  |  1996-01-15  |  1.5 KB  |  98 lines  |  [TEXT/CWIE]

  1.  
  2. // System includes
  3.  
  4. #ifndef __TYPES__
  5.     #include <Types.h>
  6. #endif
  7.  
  8. #ifndef __LISTS__
  9.     #include <Lists.h>
  10. #endif
  11.  
  12. #ifndef __OSUTILS__
  13.     #include <OSUtils.h>
  14. #endif
  15.  
  16.  
  17. // Application includes
  18.  
  19. #ifndef __BAREBONES__
  20.     #include "BareBones.h"
  21. #endif
  22.  
  23.  
  24. #ifndef USE_LDEF
  25.  
  26.  
  27. pascal void tabsLDEF ( short theMessage, short selFlags, Rect* theRect, Cell theCell,
  28.                                short theOffset, short theLen, ListRef theHandle );
  29.  
  30.  
  31.  
  32.  
  33.  
  34. #if GENERATINGPOWERPC
  35. #pragma options align=mac68k
  36. #endif
  37.  
  38.  
  39. #if GENERATINGCFM
  40. typedef struct
  41. {
  42.     RoutineDescriptor    routineDescriptor;
  43.     
  44. } LDEFPatch, *LDEFPatchPtr, **LDEFPatchHndl;
  45. #else
  46. typedef struct
  47. {
  48.     short    jmpInst;
  49.     ProcPtr    patchAddr;
  50.     
  51. } LDEFPatch, *LDEFPatchPtr, **LDEFPatchHndl;
  52. #endif
  53.  
  54. #if GENERATINGPOWERPC
  55. #pragma options align=reset
  56. #endif
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63. OSErr PatchListLDEF ( ListRef theList );
  64.  
  65.  
  66. OSErr PatchListLDEF ( ListRef theList )
  67. {
  68.     OSErr                theErr;
  69.     LDEFPatchHndl        ldefHndl;
  70.     LDEFPatchPtr        ldefPatch;
  71.     RoutineDescriptor    initializedRD = BUILD_ROUTINE_DESCRIPTOR ( uppListDefProcInfo,
  72.                                                                     tabsLDEF );
  73.     
  74.     ldefHndl = (LDEFPatchHndl) NewHandle ( sizeof ( LDEFPatch ) );
  75.     theErr = MemError ( );
  76.     if ( theErr )
  77.         return theErr;
  78.     
  79.     HLock ( (Handle) ldefHndl );
  80.     ldefPatch = *ldefHndl;
  81.     
  82. #if GENERATINGCFM
  83.     ldefPatch->routineDescriptor = initializedRD;
  84. #else
  85.     ldefPatch->jmpInst = 0x4EF9;                    // a 68K JMP instruction
  86.     ldefPatch->patchAddr = (ProcPtr) tabsLDEF;        // where we want to jmp
  87. #endif
  88.     
  89.     HUnlock ( (Handle) ldefHndl );
  90.     (*theList)->listDefProc = (Handle) ldefHndl;
  91.     
  92.     return noErr;
  93. }
  94.  
  95.  
  96. #endif
  97.  
  98.